package com.xiaoshuidi.cloud.module.report.utils;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolUtils {

    /**
     * 参数信息：
     * int corePoolSize     核心线程大小
     * int maximumPoolSize  线程池最大容量大小
     * long keepAliveTime   线程空闲时，线程存活的时间
     * TimeUnit unit        时间单位
     * BlockingQueue<Runnable> workQueue  任务队列。一个阻塞队列
     */
    public final static ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(
            4,
            20,
            10,
            TimeUnit.SECONDS,
            new ArrayBlockingQueue<>(10),
            Executors.defaultThreadFactory(),
            new ThreadPoolExecutor.DiscardOldestPolicy()
    );

}
